<html>
    <head>
        <title>List of works</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                var count=0;
                $("#add h2").click(function(){
                    $("#add table").fadeToggle();
                    if(count%2!=0)
                        $(".img_an_hien").attr('src','<?php echo base_url("public/admin/images/sq_plus_icon&24.png")?>');
                    else
                         $(".img_an_hien").attr('src','<?php echo base_url("public/admin/images/sq_minus_icon&24.png"); ?>');
                    count++;
                });
            });
        </script>   
    </head>
    <body>
        <div id="wraper">
            <?php $this->load->view('admin/menu', array('action' => $action));?>
            <div id="content">
                <?php $this->load->view('admin/forms/works_form');?>
                <?php echo validation_errors(); ?>
                <div id="search">
                   <?php echo validation_errors(); ?>
                   <?php  echo form_open('admin/works'); ?>
                            <div id="input_search">
                                <b>Site :</b>
                                <select name="id_site"> 
                                    <option value="0" selected>--Any--</option>
                                    <?php  foreach($sites as $item): ?>
                                    <option value="<?php echo $item['id'] ?>"><?php echo $item['name'] ?></option>
                                    <?php  endforeach; ?>
                                </select>
                                &nbsp;
                                <b>Keyword </b>
                                <input type="text" name="keyword" value="<?php if (isset($_GET['keyword'])) echo $_GET['keyword'];?>">
                                <input type="submit" name="search" value="Search">
                            </div>
                    </form>
                    <center>
                            <form name="export_excel" id="export_excel" method="POST">
                                <input type="submit" value="Export excel" name="submit_export_excel">
                            </form>
                    </center>
                </div><!-- End #search; -->
                <div class="total_pagination">
                        <div id="show_search" class="float_left">
                                <b>Total :&nbsp;</b>
                                About <?php echo $total_works ?> result.
                        </div>
                        <div id="pagination" class="float_right">
                            <?php echo "pagination" ?>
                        </div>
                        <div class="clear"></div>
                </div>
                <div class="show_data">
                    <table cellspacing="0" cellpadding="5" border="0" width="100%">
                        <tr>
                            <td align="center" colspan="10" valign="middle" class="title" style="padding: 15px;">WORKS</td>
                        </tr>
                        <tr>
                            <td class="title"><a href=""></a>Name</td>
                            <td class="title">Location</td>
                            <td class="title">Description</td>
                            <td class="title">Experience requirements</td>
                            <td class="title">Posted date</td>
                            <td class="title"> &nbsp; Operation &nbsp; </td>            
                        </tr>
                        <?php if (!empty($works)): $count = 0; ?>
                            <?php foreach ($works as $item): $count++; ?>
                                <tr <?php if ($count % 2 != 0) echo "class='enable'"; ?>>
                                    <td class="name"><a href="<?php echo '#'; ?>" target="_blank"><?php echo $item["name"]; ?></a></td>
                                    <td class="infor_show"><?php echo $item["location"]; ?></td>
                                    <td class="infor_show"><?php echo substr($item["description"], 0, 200); ?></td>
                                    <td class="infor_show"><?php echo substr($item["requirements"], 0, 200); ?></td>
                                    <td class="infor_show"><?php echo date("d/m/Y", $item["posted"]); ?></td>
                                    <td class="infor_show"> 
                                        <a href="view_works?id=<?php echo $item["id"]; ?>&action=<?php echo md5('edit_works');?>" class="edit" title="edit work"> Edit</a>
                                        <a href="view_works?id=<?php echo $item["id"]; ?>&action=<?php echo md5('view_works');?>" class="view" title="view work"> View</a>
                                        <a href="control_operation_works?id=<?php echo $item["id"]; ?>&action=<?php echo md5('delete_works');?>" class="delete" title="delete work"> Delete</a>
                                    </td>   
                                </tr>
                            <?php endforeach; ?>
                        <?php else : ?>
                            <div class='notice'>Not find works</div>
                        <?php endif; ?>
                    </table>
                </div><!-- End: #show_work -->
            </div><!--End: #khung-->
            <?php $this->load->view('admin/footer'); ?>
        </div><!-- End #wraper --->
    </body>
</html>
